package com.clickpaas.workinghours.bean;

import com.bizcloud.ipaas.tbba4bf83484b4ed2aacba581fbfeac4d.  d20210220155135.codegen.*;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;

@Component
public class ApiBean {
    /**
     * 对象名称:工时
     * 对象代码:t_TimeSheet
     */
    private volatile TimesheetApi _timesheetApi;
    @Bean
    public TimesheetApi ttimesheetApi(){
        try {
            return getApi(TimesheetApi.class,_timesheetApi);
        } catch (Exception e) {
            return new TimesheetApi();
        }
    }

    /**
     * 对象名称:工时填报
     * 对象代码:TimeCard
     */
    private volatile TimecardApi _timecardApi;
    @Bean
    public TimecardApi ttimecardApi(){
        try {
            return getApi(TimecardApi.class,_timecardApi);
        } catch (Exception e) {
            return new TimecardApi();
        }
    }

    /**
     * 对象名称:项目
     * 对象代码:ProjectApi
     */
    private volatile PmsprojectApi _pmsProjectApi;
    @Bean
    public PmsprojectApi pmsprojectApi(){
        try {
            return getApi(PmsprojectApi.class,_pmsProjectApi);
        } catch (Exception e) {
            return new PmsprojectApi();
        }
    }

    /**
     * 对象名称:商机
     * 对象代码:OpportunityApi
     */
    private volatile OpportunityApi _opportunityApi;
    @Bean
    public OpportunityApi stdopportunityApi(){
        try {
            return getApi(OpportunityApi.class,_opportunityApi);
        } catch (Exception e) {
            return new OpportunityApi();
        }
    }

    /**
     * 对象名称:市场活动
     * 对象代码:Campaign
     */
    private volatile CampaignApi _campaignApi;
    @Bean
    public CampaignApi campaignApi(){
        try {
            return getApi(CampaignApi.class,_campaignApi);
        } catch (Exception e) {
            return new CampaignApi();
        }
    }

    /**
     * 对象名称:WBS
     * 对象代码:WBS
     */
    private volatile WbsApi _wbsApi;
    @Bean
    public WbsApi wbsApi(){
        try {
            return getApi(WbsApi.class,_wbsApi);
        } catch (Exception e) {
            return new WbsApi();
        }
    }

    /**
     * 对象名称:工时日期
     * 对象代码:TimeCardDate
     */
    private volatile TimecarddateApi _timecarddateApi;
    @Bean
    public TimecarddateApi timecarddateApi(){
        try {
            return getApi(TimecarddateApi.class,_timecarddateApi);
        } catch (Exception e) {
            return new TimecarddateApi();
        }
    }

    /**
     * 对象名称:线索
     * 对象代码:Lead
     */
    private volatile LeadApi _leadApi;
    @Bean
    public LeadApi leadApi(){
        try {
            return getApi(LeadApi.class,_leadApi);
        } catch (Exception e) {
            return new LeadApi();
        }
    }

    /**
     * 延迟加载
     * @param clazz
     * @param cla
     * @param <T>
     * @return
     * @throws Exception
     */
    private  <T> T getApi(Class<T> clazz,T cla) throws Exception {
        if (null == cla){
            synchronized (clazz){
                if (null == cla){
                    cla = clazz.newInstance();
                }
            }
        }
        return cla;
    }
}
